package com.cskaoyan.dbutils.handler;

import com.cskaoyan.bean.Account;
import com.cskaoyan.connectionpool.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.MapListHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * 创建日期: 2022/03/24 14:49
 *
 * @author ciggar
 */
public class MapListHandlerDemo {

    public static void main(String[] args) throws SQLException {

        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        List<Map<String, Object>> mapList = queryRunner.query("select * from account", new MapListHandler());

        System.out.println(mapList);

        Map<String, Object> map = mapList.get(0);

        Integer id = (Integer) map.get("id");

        System.out.println("id:" + id);

    }

}
